LAM-1287: Add notification logging to ClickHouse and Slack subscription for reports#1395
Open
laminar-coding-agent[bot] wants to merge 4 commits intodevfrom
Open
LAM-1287: Add notification logging to ClickHouse and Slack subscription for reports#1395laminar-coding-agent[bot] wants to merge 4 commits intodevfrom
laminar-coding-agent[bot] wants to merge 4 commits intodevfrom
Conversation
…on for reports - Add ClickHouse `notification_log` table (migration 27) to record every email and Slack notification with recipient, subject, body, status, and error details for auditing and inspection. - Update NotificationHandler to write to ClickHouse after each send, capturing both successes and failures per recipient. - Add `workspace_id` field to NotificationMessage so logs can be queried per workspace. - Add Slack report targets: new `get_report_target_slack_channels` query in db/reports.rs and `ReportSummary` variant in SlackMessagePayload with formatted Block Kit messages. - Update report generator to push Slack notifications alongside emails when Slack targets are configured for a report. - Update frontend reports UI to show both email toggle and Slack channel selector per report, backed by discriminated-union Zod schemas for opt-in/opt-out of EMAIL and SLACK target types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use uncontrolled Select so the same channel can be re-selected after unsubscribing. Previously selectedChannelId local state was never reset, preventing Radix onValueChange from firing on re-selection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Set notification_type to "report" or "alert" based on event_name prefix instead of duplicating event_name. This allows filtering the audit log by notification category as intended. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Look up workspace_id from project_id via a lightweight DB query so signal alert notifications are logged with the correct workspace_id in ClickHouse, making them queryable by workspace. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
notification_logtable to record every email and Slack notification with full details (recipient, subject, body, status, error) for auditing and inspection. Records are ordered by(workspace_id, created_at)with a 90-day TTL.NotificationHandlernow writes a log entry to ClickHouse after each email/Slack send, capturing both successes and failures per recipient. Addedworkspace_idtoNotificationMessagefor queryability.ReportSummaryvariant toSlackMessagePayloadandget_report_target_slack_channelsDB query.Changed files
Backend (Rust)
app-server/src/ch/notification_log.rs— new CH insert module for notification_logapp-server/src/ch/mod.rs— register notification_log moduleapp-server/src/db/reports.rs— addget_report_target_slack_channelsqueryapp-server/src/notifications/mod.rs— add ClickHouse logging after send, addworkspace_idto messageapp-server/src/notifications/slack.rs— addReportSummarypayload variant with Block Kit formattingapp-server/src/reports/generator.rs— push Slack notifications for reports alongside emailsapp-server/src/main.rs— pass ClickHouse client to NotificationHandlerapp-server/src/signals/postprocess.rs— addworkspace_idfield to notification messageFrontend (TypeScript)
frontend/lib/clickhouse/migrations/27_notification_log.sql— new ClickHouse migrationfrontend/lib/actions/reports/index.ts— discriminated union schemas for EMAIL/SLACK opt-in/opt-outfrontend/components/workspace/reports/index.tsx— add Slack integration, channels, and handlersfrontend/components/workspace/reports/reports-list.tsx— email toggle + Slack channel selector per reportfrontend/components/workspace/workspace.tsx— pass Slack props to reports componentTest plan
notification_logwith channel=email🤖 Generated with Claude Code
Note
Medium Risk
Adds new ClickHouse writes in the notification hot path and expands report delivery to Slack; failures or schema mismatches could affect notification processing and increase operational load.
Overview
Adds notification auditing by introducing a ClickHouse
notification_logtable (90-day TTL) and writing per-send entries for both email and Slack, including success/error status, recipient, and rendered body/blocks.Extends report delivery to support Slack: report generation now reads Slack targets, enqueues
report_slackmessages with a newSlackMessagePayload::ReportSummary(Block Kit formatting), and the notifications worker now carriesworkspace_idonNotificationMessage(resolved for alerts and passed through for reports).Updates the reports UI and API payloads to manage both email and Slack subscriptions: per-report email toggle plus Slack channel selector/unsubscribe, with server-side Zod validation via discriminated unions and one Slack channel enforced per report.
Written by Cursor Bugbot for commit d015d79. This will update automatically on new commits. Configure here.